package user.zc.helper;

import user.zc.excel.render.ICreate;
import user.zc.file.OutputResource;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelWriteUtil {
    private ICreate create;
    private OutputResource outputResource;

    public ExcelWriteUtil(ICreate create, OutputResource outputResource) {
        this.create = create;
        this.outputResource = outputResource;
    }

    public void general(){
        outputResource.write((XSSFWorkbook) create.next());
    }

    public static class ExcelWriteUtilBuilder{
        private ICreate create;
        private OutputResource outputResource;
        public ExcelWriteUtilBuilder create(ICreate create){
            this.create = create;
            return this;
        }
        public ExcelWriteUtilBuilder outputResource(OutputResource outputResource){
            this.outputResource = outputResource;
            return this;
        }
        public ExcelWriteUtil build(){
            return new ExcelWriteUtil(this.create,this.outputResource);
        }
    }

    public static ExcelWriteUtilBuilder builder() {
        return new ExcelWriteUtilBuilder();
    }

}
